package esempi.graphics;

import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * This example shows how to open two JFrame. 
 * 
 * @author Alessandro Martinelli
 */
public class Esempio01SimpleShapes extends JPanel{

	public static void main(String[] args) {
		JFrame frame1=new JFrame();
		frame1.setSize(270,70);
		frame1.setTitle("java.awt.Graphics");
		frame1.getContentPane().add(new Esempio01SimpleShapes());
		frame1.setVisible(true);
		frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	@Override
	protected void paintComponent(Graphics graphics) {
		super.paintComponent(graphics);
	
		//Rettangolo
		graphics.drawRect(10, 10, 30, 20);
		
		//Ovale
		graphics.drawOval(50, 10, 30, 20);
		
		//Triangolo
		int xs[]={90,90,120};
		int ys[]={10,30,30};
		graphics.drawPolygon(xs,ys,3);
		
		//Rettangolo con gli angoli smussati
		graphics.drawRoundRect(130, 10, 30, 20, 10, 10);
	
		//Arco d'Ellisse
		graphics.drawArc(170, 10, 30, 20, 0, 270);
		
		graphics.drawString("Ciao", 210, 30);
	}
}
